define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'share/usert/index' + location.search,
                    del_url: 'share/usert/del',
                    table: 'share_user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns:true,
                fixedRightNumber:1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'user.nickname', title: '姓名',operate:'LIKE'},
                        {field: 'user.username', title: '账号',operate:'LIKE'},
                        {field: 'user.mobile', title: '手机号',operate:'LIKE'},
                        {field: 'role', title: __('Role'), searchList: {"0":__('无'),"1":__('推广员'),"2":__('代言人'),"3":__('一星网店经销商'),"4":__('二星网店经销商'),"5":__('银牌经销商'),"6":__('金牌经销商'),"7":__('钻石经销商')}, formatter: Table.api.formatter.status},
                        {field: 'role_url', title: '网体路径',operate:'LIKE', visible: false},
                        {field: 'inviter_id', title: __('Inviter_id')},
                        // {field: 'user.invitecode', title: '邀请码',operate:false},
                        {field: 'addtime', title: __('Addtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'parent_id', title: __('Parent_id')},
                        {field: 'price', title: __('Price'), operate:false},
                        {field: 'total_price', title: __('Total_price'), operate:false},
                        {field: 'amount', title: '团队人数', operate:false},
                        {field: 'score', title: '积分', operate:false},
                        {field: 'role_type', title: '所在团队', operate:false},
                        {field: 'role1', title: '团队1', operate:false, searchList: {"0":__('无'),"1":__('推广员'),"2":__('代言人'),"3":__('一星网店经销商'),"4":__('二星网店经销商'),"5":__('银牌经销商'),"6":__('金牌经销商'),"7":__('钻石经销商')},formatter: Table.api.formatter.status},
                        {field: 'role2', title: '团队2', operate:false,searchList: {"0":__('无'),"1":__('推广员'),"2":__('代言人'),"3":__('一星网店经销商'),"4":__('二星网店经销商'),"5":__('银牌经销商'),"6":__('金牌经销商'),"7":__('钻石经销商')}, formatter: Table.api.formatter.status},
                        {field: 'role3', title: '团队3', operate:false,searchList: {"0":__('无'),"1":__('推广员'),"2":__('代言人'),"3":__('一星网店经销商'),"4":__('二星网店经销商'),"5":__('银牌经销商'),"6":__('金牌经销商'),"7":__('钻石经销商')}, formatter: Table.api.formatter.status},
                        {field: 'is_union', title: __('是否联创伙伴'), searchList: {"0":__('否'),"1":__('是')}, formatter: Table.api.formatter.is_union},
                        {field: 'is_sep_income', title: __('是否分割'), searchList: {"0":__('否'),"1":__('是')}, formatter: Table.api.formatter.is_union},
                        {field: 'user_flags', title: __('分割标识')},
                        {
                            field: 'operate',
                            title: __('Operate'), table: table,
                            events: Table.api.events.operate,
                            buttons: [

                            ],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        change: function () {
            Controller.api.bindevent();
        },
        addchange:function(){
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
